package com.cloudwise.monitoring_system.service.clickhouseService.impl;

import com.cloudwise.monitoring_system.dao.clickhouseDao.CkMonitorUnitDao;
import com.cloudwise.monitoring_system.entity.MonitorUnit;
import com.cloudwise.monitoring_system.service.clickhouseService.CkMonitorUnitService;
import com.cloudwise.monitoring_system.annotation.DS;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (MonitorUnit)表服务实现类
 *
 * @author makejava
 * @since 2021-05-28 10:53:33
 */
@Service("ckMonitorUnitService")
public class CkMonitorUnitServiceImpl implements CkMonitorUnitService {
    @Resource
    private CkMonitorUnitDao ckMonitorUnitDao;

    /**
     * 通过ID查询单条数据
     *
     * @param unitId 主键
     * @return 实例对象
     */
    @Override
    @DS("db2")
    public MonitorUnit queryById(Integer unitId) {
        return this.queryById(unitId);
    }

    /**
     * 新增数据
     *
     * @param monitorUnit 实例对象
     * @return 实例对象
     */
    @Override
    @DS("db2")
    public MonitorUnit insert(MonitorUnit monitorUnit) {
         this.ckMonitorUnitDao.insert(monitorUnit);
        return monitorUnit;
    }
    /**
     * 修改数据
     *
     * @param monitorUnit 实例对象
     * @return 实例对象
     */
    @Override
    @DS("db2")
    public MonitorUnit update(MonitorUnit monitorUnit) {
         this.ckMonitorUnitDao.update(monitorUnit);
         return monitorUnit;
    }
    /**
     * 通过主键删除数据
     *
     * @param unitId 主键
     * @return 是否成功
     */
    @Override
    @DS("db2")
    public boolean deleteById(Integer unitId) {
        return this.ckMonitorUnitDao.deleteById(unitId)>0;
    }
    /**
     * 查询所有数据
     * @param monitorUnit
     * @return
     */
    @Override
    @DS("db2")
    public List<MonitorUnit> queryAll(MonitorUnit monitorUnit) {
        return this.ckMonitorUnitDao.queryAll(monitorUnit);
    }

    /**
     * 通过监控项名字查询监控项id
     * @param monitorUnit
     * @return
     */
    @Override
    @DS("db2")
    public MonitorUnit queryByName(MonitorUnit monitorUnit) {
        return this.ckMonitorUnitDao.queryByName(monitorUnit);
    }
}
